<?php
/**
 * Packager workflow entry point.
 * 
 * This is used to setup all the source files to be compiled
 * into which compiled file.
 * 
 * @package BB.Toolkit.Packager
 * @author Ben.Blanks
 * @since 1.0
 */
require('../classes/packager.class.php');

$oPackager = new Packager(array(
  'type'        => 'css',
  'cache_dir'   => dirname( __FILE__ ).'/cache/',
  'src_dir'     => dirname( __FILE__ ).'/src/',
  'build_dir'   => dirname( __FILE__ ).'/',
  'minify'      => true,
  'gzip'        => true
));
/**
 * Files to be added to the script files being processed into one file.
 * 
 * The filename is generated from the first parameter of the AddFile Method
 * and the filename given to the Process method.
 * 
 * eg.
 * $oPackager->AddFile( 'screen.css' , 'layout.css' );
 * $oPackager->AddFile( 'screen.css' , 'styles.css' );
 */

/**
 * Files to be locked at a specific version as they are not to be checked
 * every single load. This must contain the source file path. See below.
 */
//$oPackager->LockFile( 'layout.css' );

/**
 * Publish / Render the javascript file requested.
 */
$sFilePath         = $_SERVER['REQUEST_URI'];
$iFileName_Start   = (strrpos( $sFilePath , '/' )+1);
$iFileName_End     = (strrpos( $sFilePath , '?' ));
if( $iFileName_End > 0 ) {
  $iFileName_End = ($iFileName_End-$iFileName_Start);
}
else {
  $iFileName_End = strlen( $sFilePath );
}
$sFileName         = substr( $sFilePath , $iFileName_Start , $iFileName_End );
$oPackager->Process( $sFileName , 'render' );